package Final;

import javax.swing.*;

import java.awt.*;
import java.awt.event.*;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class ProfileEntry extends JFrame {

	JLabel FirstNameL = new JLabel("First Name");
	JTextField FirstNameT = new JTextField(10);
	JLabel LastNameL = new JLabel("Last Name");
	JTextField LastNameT = new JTextField(10);
	JPanel panel = new JPanel();
	JButton addb = new JButton("Add");
	JButton cancelb = new JButton("Cancel");
	String Fname, Lname;
	
	FileWriter fw= new FileWriter("Profile Master.csv", true);
	PrintWriter outputFile = new PrintWriter(fw);
	 
	public ProfileEntry() throws IOException{
		super("Profile Entry");
		setSize(1200,650);
		setLocation(100,50);
		panel.setLayout (null); 
		
		FirstNameL.setBounds(70,50,150,60);
		FirstNameT.setBounds(170, 50, 80, 20);
		LastNameL.setBounds(280, 50,150,60);
		LastNameT.setBounds(380, 50, 80, 20);
		addb.setBounds(50,550,80,20);
		cancelb.setBounds(160,550,80,20);
		
		panel.add(FirstNameL);
		panel.add(FirstNameT);
		panel.add(LastNameL);
		panel.add(LastNameT);
		panel.add(addb);
		panel.add(cancelb);
		
		Fname = FirstNameT.getText().toString();
		Lname = LastNameT.getText().toString();
				
		outputFile.print(Fname +", ");
		outputFile.print(Lname + ", ");
		
		getContentPane().add(panel);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setVisible(true);
		actioncompany();
		outputFile.close();	
	}

	public void actioncompany(){
		addb.addActionListener(new ActionListener() {
	
			public void actionPerformed(ActionEvent ae) {
				
				dispose();

			}
		});
		
		cancelb.addActionListener(new ActionListener() {
			
			public void actionPerformed(ActionEvent ae) {
				dispose();

			}
		});
		
	}
	
	
	public static void main(String[] args) throws IOException  {

		new ProfileEntry();
	}
	
}